import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    nodes: [],
    relationships: [],
    loading: false
  },
  mutations: {
    SET_NODES(state, nodes) {
      state.nodes = nodes
    },
    SET_RELATIONSHIPS(state, relationships) {
      state.relationships = relationships
    },
    SET_LOADING(state, loading) {
      state.loading = loading
    }
  },
  actions: {
    setNodes({ commit }, nodes) {
      commit('SET_NODES', nodes)
    },
    setRelationships({ commit }, relationships) {
      commit('SET_RELATIONSHIPS', relationships)
    },
    setLoading({ commit }, loading) {
      commit('SET_LOADING', loading)
    }
  },
  getters: {
    nodes: state => state.nodes,
    relationships: state => state.relationships,
    loading: state => state.loading
  }
})